﻿using System.ComponentModel;
using System.Windows.Forms;
using Medicalsystem.MCP.FormDesigner.Property;

namespace Medicalsystem.MCP.FormDesigner.MyControls
{
    /// <summary>
    /// MultiTextBox 控件与属性编辑器交互
    /// </summary>
    public class GetMultiTextBoxProperty : GetCtrlUIProperty
    {
        public GetMultiTextBoxProperty(MultiTextBox multiTxt)
            : base(multiTxt)
        {
            _multiTxt = multiTxt;
        }

        private MultiTextBox _multiTxt = null;

        /// <summary>
        /// 最大长度
        /// </summary>
        [CategoryAttribute("行为")]
        [ShowChinese("最大长度")]
        [Description("可输入的最大字符长度")]
        public int MaxLength
        {
            get
            {
                return _multiTxt.MaxLength;
            }
            set
            {
                this.OnSetPropertyBatch(this, "MaxLength", value);
            }
        }

        /// <summary>
        /// 只读
        /// </summary>
        [CategoryAttribute("行为")]
        [ShowChinese("只读")]
        [Description("是否可以输入值")]
        public bool ReadOnly
        {
            get { return _multiTxt.ReadOnlyZ; }
            set
            {
                this.OnSetPropertyBatch(this, "ReadOnly", value);
            }
        }

        /// <summary>
        /// 字体位置
        /// </summary>
        [CategoryAttribute("外观")]
        [ShowChinese("字体位置")]
        [Description("字体位置")]
        [Browsable(true)]
        public HorizontalAlignment TextBoxTextAlign
        {
            get
            {
                return _multiTxt.TextAlign;
            }
            set
            {
                this.OnSetPropertyBatch(this, "TextBoxTextAlign", value);
            }
        }

        /// <summary>
        /// 指定哪些滚动条在控件上可见
        /// </summary>
        [CategoryAttribute("外观")]
        [ShowChinese("滚动条")]
        [Description("显示哪些滚动条")]
        public virtual ScrollBars ScrollBars
        {
            get
            {
                return _multiTxt.ScrollBars;
            }
            set
            {
                this.OnSetPropertyBatch(this, "ScrollBars", value);
            }
        }

        public override void SetProperty(string propertyName, object value)
        {
            switch (propertyName.ToLower())
            {
                case "maxlength":
                    _multiTxt.MaxLength = (int)value;
                    break;

                case "readonly":
                    _multiTxt.ReadOnlyZ = (bool)value;
                    break;

                case "textboxtextalign":
                    _multiTxt.TextAlign = (HorizontalAlignment)value;
                    break;

                case "scrollbars":
                    _multiTxt.ScrollBars = (ScrollBars)value;
                    break;
                default:
                    base.SetProperty(propertyName, value);
                    break;
            }
        }
    }
}